package com.iknow.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import com.iknow.IKnow;
import com.iknow.app.IKnowSystemConfig;
import com.iknow.util.StringUtil;
import com.iknow.view.widget.UpdateTipDialog;

public class HomeActivity extends MenuActivity
{
  private View.OnClickListener RadioButtonClickListener;
  private Intent mFlagInent;
  private Intent mFollowIntent;
  private TabHost mHost;
  private Intent mNewQingboIntent;
  private RadioGroup mRadioGroup;
  private ImageView mRadioGroupBg;
  private boolean mTabChanged;

  public HomeActivity()
  {
    this.RadioButtonClickListener = new View.OnClickListener(this)
    {
      public void onClick()
      {
        if (HomeActivity.access$0(this.this$0))
          HomeActivity.access$1(this.this$0, false);
        while (true)
        {
          Activity localActivity;
          do
            while (true)
            {
              return;
              localActivity = this.this$0.getCurrentActivity();
              if (!(localActivity instanceof QingboWithNoHeaderActivity))
                break;
              ((QingboWithNoHeaderActivity)localActivity).onTabClick();
            }
          while (!(localActivity instanceof MySubscribeActivity));
          ((MySubscribeActivity)localActivity).onTabClick();
        }
      }
    };
  }

  private void initButton()
  {
    this.mRadioGroup = ((RadioGroup)findViewById(2131296334));
    this.mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(this)
    {
      public void onCheckedChanged(, int paramInt)
      {
        int i = paramRadioGroup.indexOfChild((RadioButton)paramRadioGroup.findViewById(paramInt));
        HomeActivity.access$2(this.this$0).setCurrentTab(i);
        HomeActivity.access$1(this.this$0, true);
        if (i == 0)
          HomeActivity.access$3(this.this$0).setBackgroundResource(2130837597);
        while (true)
        {
          do
            while (true)
            {
              return;
              if (1 != i)
                break;
              HomeActivity.access$3(this.this$0).setBackgroundResource(2130837599);
            }
          while (2 != i);
          HomeActivity.access$3(this.this$0).setBackgroundResource(2130837601);
        }
      }
    });
    ((RadioButton)findViewById(2131296347)).setOnClickListener(this.RadioButtonClickListener);
    ((RadioButton)findViewById(2131296348)).setOnClickListener(this.RadioButtonClickListener);
    ((RadioButton)findViewById(2131296349)).setOnClickListener(this.RadioButtonClickListener);
    this.mRadioGroupBg = ((ImageView)findViewById(2131296346));
  }

  private void initIntents()
  {
    this.mFollowIntent = new Intent(this, FollowActivity.class);
    this.mNewQingboIntent = new Intent(this, NewQingboActivity.class);
    this.mFlagInent = new Intent(this, MySubscribeActivity.class);
  }

  private void initTabPage()
  {
    TabHost.TabSpec localTabSpec1 = this.mHost.newTabSpec("follow");
    localTabSpec1.setContent(this.mFollowIntent);
    localTabSpec1.setIndicator("follow");
    this.mHost.addTab(localTabSpec1);
    TabHost.TabSpec localTabSpec2 = this.mHost.newTabSpec("new");
    localTabSpec2.setContent(this.mNewQingboIntent);
    localTabSpec2.setIndicator("new");
    this.mHost.addTab(localTabSpec2);
    TabHost.TabSpec localTabSpec3 = this.mHost.newTabSpec("flag");
    localTabSpec3.setContent(this.mFlagInent);
    localTabSpec3.setIndicator("flag");
    this.mHost.addTab(localTabSpec3);
  }

  private void showUpdateTips()
  {
    String str = IKnow.mSystemConfig.getString("local_version");
    try
    {
      PackageInfo localPackageInfo = getPackageManager().getPackageInfo("com.iknow", 16384);
      if ((StringUtil.isEmpty(str)) || (!(str.equalsIgnoreCase(localPackageInfo.versionName))))
      {
        IKnow.mSystemConfig.setString("local_version", localPackageInfo.versionName);
        new UpdateTipDialog(getCurrentActivity().getParent()).show();
      }
      return;
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
      localNameNotFoundException.printStackTrace();
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    requestWindowFeature(1);
    setContentView(2130903081);
    this.mHost = getTabHost();
    initIntents();
    initButton();
    initTabPage();
    showUpdateTips();
  }

  protected void onDestroy()
  {
    super.onDestroy();
  }
}